home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / PROGMISC / FPCDOCS.LZH / TOOLS.DOC < prev    next >
Text File  |  1988-06-01  |  17KB  |  455 lines

  1. III.   PROGRAMMING TOOLS 
  2.  
  3.  
  4.  
  5. 1.   DUMP
  6.  
  7.  
  8.  
  9. The dump utility gives you a formatted hex dump with the ascii 
  10. text corresponding to the bytes on the right hand side of the 
  11. screen.   DUMP displays memory in the code segment, where code, 
  12. strings, and other data are stored.  XDUMP displays the list 
  13. segment, where colon definitions are stored.  YDUMP displays the 
  14. header segment.  These dump utilities are derived from the generic 
  15. dump function LDUMP, which displays a range of memory from a 
  16. memory segment whose segment address is stored in a variable 
  17. DUMPSEG.  DUMP, XDUMP, and YDUMP set DUMPSEG to the corresponding 
  18. segment and then do LDUMP.  One can store any segment address into 
  19. DUMPSEG and use LDUMP to display that part of the memory, the dump 
  20. segment, up to 64K bytes. 
  21.  
  22. LDUMP does not change DUMPSEG but DUMP, XDUMP, and YDUMP do change 
  23. DUMPSEG to cs:, xs:, and ys:.  Their behavior takes a little bit 
  24. of getting use to, but they allow you to navigate through the 
  25. entire segmented memory space. 
  26.  
  27. DUMPC@L fetches a byte in the segment specified by DUMPSEG. 
  28.  
  29. DU displays 64 bytes in the dump segment and increment the memory 
  30. address by 64 so that you can continue dumping the next 64 bytes 
  31. with another DU. 
  32.  
  33.   
  34.  
  35. 2.   THE DEBUGGER 
  36.  
  37.  
  38.  
  39. The debugger is very similar to the F83 debugger.  Some features 
  40. have been added to enhance its operation.  The decompiled source 
  41. for the current definition being debugged is displayed while 
  42. debugging. A typical command sequence might be as follows: 
  43.  
  44.                 DEBUG WORDS <enter>     specify WORDS to be debugged
  45.                                         as soon as it is executed.
  46.                         or
  47.  
  48.                 DBG WORDS <enter>       debug WORDS right now.
  49.  
  50. Once in the debugger, you will be shown a display similar to the 
  51. following: 
  52.  
  53.                 17469   INWFLG          ?>  _
  54.  
  55. At this point, pressing return will cause the word INWFLG to be 
  56. executed, and the debugger will print the stack after execution, 
  57. and step to the next word in the list and wait for a command.  
  58. Notice the fields in the above example.  The number on the left is 
  59. the address in memory where the debugger is currently working.  
  60. The next word INWFLG is the word the debugger is about to execute.  
  61. The next symbol "?>" is a marker pointing to what will be the 
  62. printed stack contents after we press <enter>.  The question mark 
  63. symbol is the command we must press to see the command list for 
  64. the debugger.  If we press that now, we will see: 
  65.  
  66.                 C-cont, F-forth, Q-quit, N-nest, U-unnest:
  67.  
  68. These are the commands you can use in the debugger.  Their 
  69. functions are as follows: 
  70.  
  71.         C-cont          Trace continuously until a key is pressed.
  72.  
  73.         F-forth         Allow entry of Forth command lines until
  74.                         <enter> is pressed on an empty line.
  75.  
  76.         Q-quit          Quit the debugger, and unpatch next.
  77.  
  78.         N-nest          Nest into the ":" definition we were about 
  79.                         to execute.  Only works on ":" definitions,
  80.                         and deferred words.
  81.  
  82.         U-unnest        Unnest the current ":" definition being
  83.                         debugged.  Re-enters the debugger on the next
  84.                         higher level.
  85.  
  86. You will have noticed that the upper portion of the screen is 
  87. filled with the source for the word you are currently debugging.  
  88. This is to make it easier to follow the debug process. You may 
  89. want to turn off the source display, if it interferes with your 
  90. the debuging process. The words to control this are: 
  91.  
  92.                 SRCOFF          turn off the source display
  93.                 SRCON           turn on the source display
  94.  
  95. The default state is ON. 
  96.  
  97. DEBUG only sets the debugger up to debug a word.  The debugging 
  98. process does not start until the word is executed.  A new 
  99. debugging command DBG is added, which caused the following word to 
  100. be executed and debugged immediately.  The command sequence is:
  101.  
  102.                DBG <word_name> <enter>
  103.  
  104. It is much easier to use and makes much of the intricate behavior 
  105. of the F83 DEBUG transparent to the user. 
  106.  
  107.  
  108.  
  109. 3.   CONSTANTS AS VARIABLES  
  110.  
  111.  
  112. "Constants aren't; variables won't". 
  113.  
  114. A set of operators has been included for manipulating constants.  
  115. Since constants are faster at run time than variables, performance 
  116. in critical operations can take advantage of these.  They may also 
  117. provide a somewhat more readable source.  Here is a list of them: 
  118.  
  119.                 =:              value =: constant-name 
  120.                                 assign value to constant 
  121.  
  122.                 !>              value !> constant-name 
  123.                                 assign value into constant-name 
  124.  
  125.                 @>              @> constant-name ( --- n1 ) 
  126.                                 returns contants of its BODY. 
  127.  
  128.                 +!>             value +!> constant-name 
  129.                                 increment constant-name by value 
  130.  
  131.                 incr>           incr> constant-name 
  132.                                 increment constant-name by one 
  133.  
  134.                 decr>           decr> constant-name 
  135.                                 decrement constant-name by one 
  136.  
  137. These operators are written in assembly, so they will be very 
  138. fast. 
  139.  
  140.  
  141.  
  142. 4.  HELP SEE WORDS' VIEW? 
  143.  
  144.  
  145.  
  146. F-PC provides the standard F83 decompiler, called SEE.  SEE has
  147. been modified to display a decompiled source that is in most cases 
  148. very similar to the original source on disk. 
  149.  
  150. VIEW behaves identically as that in F83.  It opens the .SEQ file 
  151. in which a word is defined and displays 16 lines of source code 
  152. from the beginning of the definition.  You can use the ED command 
  153. to enter the editor and exploring the source code before or after 
  154. this definition.  Alternatively, you can use the B or N commands 
  155. to examine the source one screen at a time without leaving F-PC
  156. even temporarily.
  157.  
  158. HELP is a new function added in F-PC, which opens the companion
  159. .HLP file to the .SEQ file in which a word is defined and displays 
  160. the help messages associated with the word.  It assumes that the 
  161. help file exists; otherwise, a file error message will be 
  162. displayed.
  163.  
  164. WORDS behaves identically as WORDS in F83 when used normally to 
  165. display the names of definitions in the CONTEXT vocabulary.  It is 
  166. enhanced in F-PC such that if the string following it is not a
  167. valid name in the CONTEXT vocabulary, it will use the string as a 
  168. substring pattern and prints the names of all definitions in all 
  169. vocabularies, whose name contains the substring.  The special 
  170. string '*.*' given after WORDS causes all words in all 
  171. vocabularies to be displayed. 
  172.  
  173.  
  174.  
  175. 5.   DATE AND TIME
  176.  
  177.  
  178.  
  179. A complete set of time and date manipulation words has been 
  180. provided in F-PC.  They call appropriate DOS service functions to
  181. produce the needed services.  The words for getting and setting 
  182. the date and time are as follows: 
  183.  
  184.                 GETDATE         ( --- d1 ) 
  185.  
  186. Return d1 the 32bit binary date from the operating system. 
  187.  
  188.                 SETDATE         ( d1 --- ) 
  189.  
  190. Given the binary date d1, set the system clock to that date. Bytes 
  191. in d1 are arranged as year/month/day/day-of-week. 
  192.  
  193.                 GETTIME         ( --- d1 ) 
  194.  
  195. Return d1 with bytes arranged in the order hr/min/sec/100th-sec 
  196. from the operating system. 
  197.  
  198.                 SETTIME         ( d1 --- ) 
  199.  
  200. Given the binary time d1, set the system clock to that time. 
  201.  
  202.                 .DATE           ( --- ) 
  203.  
  204. Print to the screen, the current date, in the format MM/DD/YY, 
  205. where MM is month, DD is day, and YY is year. 
  206.  
  207.                 .TIME           ( --- ) 
  208.  
  209. Print to the screen, the current time, in the format HH:MM:SS.HR, 
  210. where HH is hours, MM is minutes, ss is seconds, and HR is 
  211. hundredths of a second. 
  212.  
  213. A special word set is defined in F-PC for measuring elapsed time
  214. for real time experiments and for program characterization. 
  215.  
  216.                 TIMER           ( words --- )
  217.  
  218. TIMER performs the Forth words following on the same command line, 
  219. and when they finish execution, TIMER prints the elapsed time 
  220. required for their execution. 
  221.  
  222.                 TIME-RESET      ( --- )
  223.  
  224. Reset the accumulated time value in the double variable STIME to 
  225. zero, in effect resetting the current elapsed time to zero.  This 
  226. word is used at the beginning of a sequence of operations you want 
  227. to time.  The word .ELAPSED is used at the end of the operations 
  228. to print the elapsed time since the last TIME-RESET. 
  229.  
  230.                 .ELAPSED        ( --- )
  231.  
  232. Print the elapsed time since the last TIME-RESET was performed. 
  233.  
  234.                 TENTHS          ( tenths_ofa_second --- )
  235.                 SECONDS         ( seconds --- )
  236.                 MINUTES         ( minutes --- )
  237.                 HOURS           ( hours --- )
  238.  
  239. Time delay words use the system time function to obtain very 
  240. accurate time delays.  Background processing continues, as pause 
  241. is called in the wait loop.  Another deferred word, PAUSE-FUNC, is 
  242. also in the loop, which can be re deferred to perform any function 
  243. you want done while the delay is occurring. 
  244.  
  245.  
  246.  
  247. 6.   COMMENTS 
  248.  
  249.  
  250.  
  251. All comment words in F83, like (, .(, (S, \, \S are preserved and 
  252. they behave identically in F-PC.  However, a file in F-PC is similar
  253. to a block in F83 and \S stops the compilation of the rest of the 
  254. file.  To accommodate documentation which spans over many lines, 
  255. additional comment words are defined in F-PC.
  256.  
  257.  
  258. Multiple line comment in F-PC starts with COMMENT: and terminates
  259. at COMMEMT; .  It looks like:
  260.  
  261.                 COMMENT:    
  262.                 <text> 
  263.                 <more text>
  264.                 ... 
  265.                 <even more text>
  266.                 COMMENT; 
  267.  
  268. To print multiple line comments during compiling, 
  269.  
  270.                 .COMMENT:        ( lines_of_text --- )
  271.                 ...
  272.                 COMMENT; 
  273.  
  274. Starts a group of lines, that are to be printed to the terminal, 
  275. until a terminating "COMMENT;" is found. 
  276.  
  277.  
  278.  
  279. 7.  SCREEN CONTROL WORDS IN F-PC
  280.  
  281.  
  282.  
  283. F-PC allows you to control the CRT screen to generate very fancy
  284. text displays.  Most of these screen control words call DOS video 
  285. service to change the character attributes on characters emitted 
  286. to the screen. 
  287.  
  288.                 FAST            ( --- )
  289.  
  290. Select the Fast screen output routines that are very hardware 
  291. dependant.  Much faster than BDOS, but requires VERY compatible 
  292. hardware. 
  293.  
  294.                 SLOW            ( --- )
  295.  
  296. Select the SLOW screen output routines, these routines use BDOS 
  297. for screen output, and are less hardware dependant than FAST. 
  298.  
  299.                 >UL             ( --- )         underline 
  300.                 >REV            ( --- )         reverse
  301.                 >BOLD           ( --- )         bold
  302.                 >BOLDUL         ( --- )         bold underline
  303.                 >BOLDBLNK       ( --- )         bold blink
  304.                 >REVBLNK        ( --- )         reverse blink
  305.                 >NORM           ( --- )         normal video
  306.  
  307. Select the various types of attributes available on the monochrome 
  308. monitor. 
  309.  
  310. COLOR support has been added.  F-PC as delivered is configured for
  311. Monochrome, but will work on a color monitor. The INSTALL process 
  312. will automatically install color support if a color board is being 
  313. used during installation. 
  314.  
  315.                 >FG             ( n1 --- )      foreground
  316.                 >BG             ( n1 --- )      background
  317.  
  318. Words from the COLOR.SEQ file that allow setting the foreground 
  319. and background colors on a color monitor: 
  320.  
  321.                 >ATTRIB1        ( --- )
  322.                 >ATTRIB2        ( --- )
  323.                 >ATTRIB3        ( --- )
  324.                 >ATTRIB4        ( --- )
  325.  
  326. Deferred words to allow selection of the various display 
  327. attributes for the current display board.  They default to the 
  328. following attributes for Monochrome and Color. 
  329.  
  330.  
  331.                                 MONOCHROME          COLOR
  332.                   word                          bgrnd   fgrnd
  333.                 ---------------------------------------------
  334.                 >ATTRIB1        UNDERLINE       BLUE    GREEN
  335.                 >ATTRIB2        BOLD UNDERLINE  RED     WHITE
  336.                 >ATTRIB3        BOLD            BLUE    WHITE
  337.                 >ATTRIB4        REVERSE         RED     WHITE
  338.  
  339. These values can be changed by changing either COLOR.SEQ, or 
  340. MONOCROM.SEQ and re-installing the system with INSTALL.BAT. 
  341.  
  342.                 SAVESCR         ( --- )         save screen 
  343.                 RESTSCR         ( --- )         restore screen
  344.  
  345. These words give you the ability to save the screen contents and 
  346. later restore the screen to its original appearance in a simple 
  347. way. SAVESCR may be used and nested up to three times before 
  348. RESTSCR needs to be done. That is, three screens can be saved and 
  349. sequentially restored. 
  350.  
  351.  
  352.  
  353. 8.   COMPILATION CONTROL WORDS
  354.  
  355.  
  356.  
  357. To load a source file, the most convenient way is to use the 
  358. command FLOAD: 
  359.  
  360.                 FLOAD <file_name> <enter>
  361.  
  362. will open the file and compile the source code start at the 
  363. beginning.  After the file is compiled, FLOAD closes the file so 
  364. that other files can be loaded.
  365.  
  366. If a file is openned by the editor, 
  367.  
  368.                 OK <enter>
  369.  
  370. compile the currently open file, starting at the beginning, and 
  371. continuing through the end of the file or until an error is 
  372. encountered. 
  373.  
  374.                 <line_number> LOAD <enter>
  375.  
  376. Start loading the current file starting at the <line_number> 
  377. specified.  Loads through the end of the file or until an error is 
  378. encountered. 
  379.  
  380. A tool of the type used in F83X has been added, called ?NEEDS. 
  381. This word when followed by a filename will conditionally load the 
  382. specified file if the file has not already been loaded. Be sure to 
  383. include the filename extension. Another word ?UNWANTED, when 
  384. followed by a filename, aborts with an error if the Unwanted file 
  385. has already been loaded. 
  386.  
  387. The word #IF has been added, which accepts a boolean flag, and 
  388. determines if the lines following #IF are loaded up until the 
  389. #ENDIF. A TRUE flag causes the lines to be loaded. A FALSE flag 
  390. causes the lines to be skipped. 
  391.  
  392.                 TRUE #IF 
  393.  
  394.                         .( This message will be printed.) 
  395.  
  396.                 #ENDIF 
  397.  
  398.  
  399.  
  400. 9.   PRINTING SOURCE FILES IN F-PC.
  401.  
  402.  
  403.  
  404. Files can of course be printed while in the editor, but you can 
  405. also print files from the Forth command line as follows: 
  406.  
  407.                 OPEN <filename> <enter>         open a file
  408.                 LISTING <enter>                 print the file
  409.  
  410. The print format is the same as the default format for the editor.  
  411. Another command which combines the two commands above is as 
  412. follows: 
  413.  
  414.                 FPRINT <filespec> <enter>       
  415.  
  416. Literally opens the file and performs a LISTING.  Wildcard 
  417. characters can be used in the file specification so that many 
  418. files are printed with a single FPRINT command.
  419.  
  420.                 INDEX <filespec> <enter>
  421.  
  422. behaves similarly to FPRINT.  However, it prints only the first 
  423. line of each file specified. 
  424.  
  425.  
  426.  
  427. 10.   GLOBAL SEARCH 
  428.  
  429.  
  430.  
  431. One of the neat additions to F-PC is EDITALL.  EDITALL is used as
  432. follows: 
  433.  
  434.         EDITALL <string> <filespecs>... <enter> 
  435.  
  436. All filespecs are searched for string, if string is found, the the 
  437. editor is entered on that line of the file, ready for you to 
  438. perform an edit or replace on the string. Only the first occurance 
  439. of string is located, so repeated Alt-F6 commands can locate 
  440. additional occurances of string in the file.  Shift-F8 Replace all 
  441. can also be used while in a file to replace all occurances of 
  442. string with another string.  When you are done editing, press ESC, 
  443. to terminate edit, and the search will continue through the 
  444. filespecs specified for additional occurances of string, until all 
  445. files have been found that contain string.  This has been very 
  446. valuble to me in maintaining the system, and making global changes 
  447. to all occurances of a Forth word name. 
  448.  
  449. FLOOK is another interesting addition to F-PC.  It performs
  450. similarly to EDITALL in searching a word through many files, but 
  451. just displays the file and line number of all occurances found. 
  452.  
  453.  
  454.  
  455.